/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package CareerService.Entitybeans;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "student")
@NamedQueries({@NamedQuery(name = "Student.findAll", query = "SELECT s FROM Student s"), @NamedQuery(name = "Student.findByStuId", query = "SELECT s FROM Student s WHERE s.stuId = :stuId"), @NamedQuery(name = "Student.findByStunum", query = "SELECT s FROM Student s WHERE s.stunum = :stunum"), @NamedQuery(name = "Student.findByFname", query = "SELECT s FROM Student s WHERE s.fname = :fname"), @NamedQuery(name = "Student.findByLname", query = "SELECT s FROM Student s WHERE s.lname = :lname"), @NamedQuery(name = "Student.findByAge", query = "SELECT s FROM Student s WHERE s.age = :age"), @NamedQuery(name = "Student.findByStartyear", query = "SELECT s FROM Student s WHERE s.startyear = :startyear"), @NamedQuery(name = "Student.findByEmail", query = "SELECT s FROM Student s WHERE s.email = :email"), @NamedQuery(name = "Student.findByPhone", query = "SELECT s FROM Student s WHERE s.phone = :phone"), @NamedQuery(name = "Student.findByCollege", query = "SELECT s FROM Student s WHERE s.college = :college"), @NamedQuery(name = "Student.findByCourse", query = "SELECT s FROM Student s WHERE s.course = :course")})
public class Student implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "stu_id")
    private Integer stuId;
    @Basic(optional = false)
    @Column(name = "stunum")
    private int stunum;
    @Basic(optional = false)
    @Column(name = "fname")
    private String fname;
    @Basic(optional = false)
    @Column(name = "lname")
    private String lname;
    @Basic(optional = false)
    @Column(name = "age")
    private short age;
    @Column(name = "startyear")
    private String startyear;
    @Basic(optional = false)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @Column(name = "phone")
    private String phone;
    @Basic(optional = false)
    @Column(name = "college")
    private String college;
    @Basic(optional = false)
    @Column(name = "course")
    private String course;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "stuId")
    private Collection<Staffstu> staffstuCollection;
    @JoinColumn(name = "cv_id", referencedColumnName = "cv_id",unique=true)
    @OneToOne(optional = true, cascade=CascadeType.ALL)
    private StuCv cvId;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    @OneToOne(optional = false)
    private Users userId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "stuId")
    private Collection<Interview> interviewCollection;

    public Student() {
    }

    public Student(Integer stuId) {
        this.stuId = stuId;
    }

    public Student(Integer stuId, int stunum, String fname, String lname, short age, String email, String phone, String college, String course) {
        this.stuId = stuId;
        this.stunum = stunum;
        this.fname = fname;
        this.lname = lname;
        this.age = age;
        this.email = email;
        this.phone = phone;
        this.college = college;
        this.course = course;
    }

    public Integer getStuId() {
        return stuId;
    }

    public void setStuId(Integer stuId) {
        this.stuId = stuId;
    }

    public int getStunum() {
        return stunum;
    }

    public void setStunum(int stunum) {
        this.stunum = stunum;
    }

    public String getFname() {
        return fname;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }

    public String getLname() {
        return lname;
    }

    public void setLname(String lname) {
        this.lname = lname;
    }

    public short getAge() {
        return age;
    }

    public void setAge(short age) {
        this.age = age;
    }

    public String getStartyear() {
        return startyear;
    }

    public void setStartyear(String startyear) {
        this.startyear = startyear;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getCourse() {
        return course;
    }

    public void setCourse(String course) {
        this.course = course;
    }

    public Collection<Staffstu> getStaffstuCollection() {
        return staffstuCollection;
    }

    public void setStaffstuCollection(Collection<Staffstu> staffstuCollection) {
        this.staffstuCollection = staffstuCollection;
    }

    public StuCv getCvId() {
        return cvId;
    }

    public void setCvId(StuCv cvId) {
        this.cvId = cvId;
    }

    public Users getUserId() {
        return userId;
    }

    public void setUserId(Users userId) {
        this.userId = userId;
    }

    public Collection<Interview> getInterviewCollection() {
        return interviewCollection;
    }

    public void setInterviewCollection(Collection<Interview> interviewCollection) {
        this.interviewCollection = interviewCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (stuId != null ? stuId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Student)) {
            return false;
        }
        Student other = (Student) object;
        if ((this.stuId == null && other.stuId != null) || (this.stuId != null && !this.stuId.equals(other.stuId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "CareerService.Entitybeans.Student[stuId=" + stuId + "]";
    }

}
